
// __filename  当前文件全路径
// __dirname   当前文件所在文件夹全路径

/**
 * path
 * api
 * 1.basename 	获取路径中基础名称 		 required:String
 * 2.dirname 	获取路径中的目录名称 	 required:String
 * 3.extname 	获取路径中的拓展名称	 required:String
 * 4.isAbsolute 获取路径是否是绝对路径	 required:String
 * 5.join 		拼接多个路径片段		required:String
 * 6.resolve 	返回一个绝对路径		required:String
 * 7.parse		返回一个对象		   	required:String
 * 8.format  	与parse 功能相反		required:Object
 * 9.normalize	规范化给定的路径		required:String
 */

// console.log(__filename);
// console.log(__dirname);

const path = require('path')

console.log(path.basename(__filename));
console.log(path.basename(__filename, '.js'));
// console.log(path.basename(__dirname));

console.log(path.dirname(__filename));

console.log(path.extname(__filename));  // .js
console.log(path.extname(__dirname));  // ""

console.log(path.isAbsolute(__dirname));
console.log(path.isAbsolute(__filename));

console.log(path.join('a/b', 'c', 'index.js'));

console.log(path.resolve());

console.log(path.parse(__filename));
// 	 root: 'D:\\',
//   dir: 'D:\\myDomain\\node\\nodejs\\examples\\path',
//   base: 'index.js',
//   ext: '.js',
//   name: 'index'

let param = {
	root: 'D:\\',
	dir: 'D:\\myDomain\\node\\nodejs\\examples\\path',
	base: 'index.js',
	ext: '.js',
	name: 'index'
}
console.log(path.format(param));

console.log(path.normalize('a/../b..c'));

